home *** CD-ROM | disk | FTP | other *** search
- // IncList.cmm - CEnvi file to list all of the #include files
- // ver.1 for C-type files in a source file.
-
- main(argc,argv)
- {
- if ( argc != 2 )
- Instructions();
- else if ( !(fp = fopen(argv[1],"rt")) )
- Instructions();
- else {
- printf("%s : \n",argv[1]);
- ListIncludeFiles(fp);
- printf("\n");
- fclose(fp);
- }
- }
-
- Instructions()
- {
- printf("\a\n");
- printf("IncList: List #include files from C-type soure files\n");
- printf("\n");
- printf("USAGE: CEnvi IncList <FileSpec>\n");
- printf("\n");
- printf("WHERE: FileSpec - specification for source file\n");
- printf("\n");
- }
-
- ListIncludeFiles(fp)
- {
- IncludeKey = "#include";
- IncludeKeyLen = strlen(IncludeKey);
-
- while ( line = fgets(fp) ) {
-
- // find a #, which may indicate #include
- if ( line = strchr(line,'#') ) {
-
- if ( !strnicmp(line,IncludeKey,IncludeKeyLen) ) {
-
- line += IncludeKeyLen;
- // skip to next char after whitespace
- while ( strchr(" \t",line[0]) )
- line++;
-
- // read between this quote char and next one
- QuoteChar = line[0];
- if ( QuoteChar != '<' && (LineEnd = strchr(++line,QuoteChar)) ) {
- LineEnd[0] = 0;
- printf(" %s\n",line);
- }
- }
- }
- }
- }
-
-